package com.ctshk.sapp.system.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.model.TokenUser;
import com.ctshk.rpc.system.dto.MainDataBankAccountDTO;
import com.ctshk.rpc.system.req.MainDataBankAccountIdReq;
import com.ctshk.rpc.system.req.MainDataBankAccountListReq;
import com.ctshk.rpc.system.req.MainDataBankAccountReq;
import com.ctshk.rpc.system.req.MainDataCurrencyAddReq;
import com.ctshk.rpc.system.service.IMainDataBankAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 銀行賬戶表 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-03-16
 */
@Api(value = "主數據銀行賬戶",tags = "主數據銀行賬戶")
@RestController
@RequestMapping("/main/data/bank/account")
public class MainDataBankAccountController extends BaseController {

    @DubboReference
    private IMainDataBankAccountService mainDataBankAccountService;

    /**
     * 新增銀行賬戶
     * @param req
     * @return
     */
    @ApiOperation(value="新增銀行賬戶", notes="新增銀行賬戶")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增銀行賬戶", operDesc = "新增銀行賬戶")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataBankAccountReq req){
        return mainDataBankAccountService.add(req,getCurrentUser(getRequest()));
    }
    /**
     * 編輯銀行賬戶
     * @param req
     * @return
     */
    @ApiOperation(value="編輯銀行賬戶", notes="編輯銀行賬戶")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "編輯銀行賬戶", operDesc = "編輯銀行賬戶")
    @PostMapping("/update")
    public Result update(@RequestBody @Valid MainDataBankAccountReq req){
        return mainDataBankAccountService.update(req,getCurrentUser(getRequest()));
    }

    /**
     * 查詢銀行賬戶
     * @param req
     * @return
     */
    @ApiOperation(value="查看銀行賬戶", notes="查看銀行賬戶")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查看銀行賬戶", operDesc = "查看銀行賬戶")
    @PostMapping("/query")
    public Result<MainDataBankAccountDTO> query(@RequestBody @Valid MainDataBankAccountIdReq req){
        return Result.success(mainDataBankAccountService.query(req));
    }

    /**
     * 查詢銀行賬戶列表
     * @param req
     * @return
     */
    @ApiOperation(value="查看銀行賬戶列表", notes="查看銀行賬戶列表")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "編輯銀行賬戶", operDesc = "編輯銀行賬戶")
    @PostMapping("/list")
    public Result<PageResponse<MainDataBankAccountDTO>> list(@RequestBody @Valid MainDataBankAccountListReq req){
        return Result.success(mainDataBankAccountService.list(req));
    }

}
